﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Product.aspx.cs" Inherits="UI_Bas_Product" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>物料管理</title>
    <meta http-equiv="x-ua-compatible" content="IE=EmulateIE8" />
    <link href="../../css/admin.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery.easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery.easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery.easyui/jquery.min.js" type="text/javascript"></script>
    <script src="../../js/jquery.easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery.easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../../js/FileUpload/ajaxfileupload.js" type="text/javascript"></script>
    
<script type="text/javascript">
    $(function() {
        var _$product = $("#product");
        _$product.datagrid({
            border: true,
            height: 355,
            title: '物料管理...',
            remoteSort: true,
            nowrap: true,
            striped: false,
            width:1100,
            url: "../../TableHanders.aspx?act=q&tid=22&type=0",
            sortName: 'ProductId',
            sortOrder: 'desc',
            loadMsg: "正在加载,请稍后...",

            frozenColumns: [[
                    { field: 'opt', title: 'Operation', width: 80, align: 'center',
                        formatter: function(val, row, index) {
                            var ProductId = row.ProductId;
                            return '<a href="#" onclick = "DeleteRow(this);" id = ' + ProductId + ' rowIndex = ' + index + ' style = "color:red;">Delete</a>  '
                                                      + '<a href = "ProductDetail.aspx?act=e&id=' + ProductId + '">Eidt</a>';
                        }
                    },
	                { title: '代码', field: 'ProductId', width: 85, sortable: true }
                     ]],
	                columns: [[
            
	                { title: '名称', field: 'ProductName', width: 600, sortable: true },
	                { title: '规格型号', field: 'ProductSpecification', width: 150, sortable: true },
	                { title: '销售状态', field: 'SalesStatus', width: 70, sortable: true, formatter: function(val) {
	                    if (val == "40005") {
	                        return "在售";
	                    }
	                    else if (val == "40006") {
	                        return "临时停售";
	                    }
	                    else if (val == "40007") {
	                        return "淘汰";

	                    }
	                    else {
	                        return "";
	                    }
	                }
	                },
	                { title: '审核人', field: 'Auser', width: 70, sortable: true }
				]],
            toolbar: [{
                text: 'Add',
                iconCls: 'icon-add',
                handler: function() {
                    window.location.href = "ProductDetail.aspx?act=I";
                }
}],
                pagination: true,
                rownumbers: true,
                singleSelect: true,
                pageList: [10, 20, 50]
            });
            $("#btnQuery").click(function() {
                var ProductId = $("#txtProductId").val();
                var txtUserCode = $("#txtUserCode").val();

                _$product.datagrid({
                    queryParams: {
                        "ProductId": ProductId,
                        "UserCode": txtUserCode
                    }
                });
            });
        });
    function DeleteRow(row) {
        var rowAttr = $(row);
        var id = rowAttr.attr('id');
        var rowIndex = rowAttr.attr('rowIndex');
        $.messager.confirm("请确认...", "确认删除?", function(value) {
            if (value) {
                var url = "../../TableHanders.aspx?act=d&tid=22&type=1&id=" + id;
                $.getJSON(url, function(data) {
                    var sdata = data[0];
                    var code = sdata.code;
                    if (code == 0) {
                        $("#product").datagrid('deleteRow', rowIndex);
                    }
                    else {
                        alert(sdata.msg);
                    }
                });

            }
        })
    }
</script>
</head>
<body>
  <div id="dd"></div>
  <div class="div_Title">
    <span class="Body_Title">》》<%=this.Title %></span>
  </div>    
  <div id="p" class="easyui-panel" title="请输入查询条件..." style="margin-bottom:5px; width:1100px;">
    <form id= "fomrquery">
      <table>
        <tr>
          <td>商品代号:</td>
          <td>
            <input id="txtProductId"  type="text"  runat="server"  ></input>
          </td>
          <td>规格型号:</td>
          <td>
            <input id="txtUserCode" type="text" runat="server">
            </td>              
          <td>
            <a id="btnQuery" href="#" class="easyui-linkbutton" icon="icon-search">Query</a>
          </td>
          </tr>
        </table>
      </form>
    </div>
    <table id="product"></table>
  </div>
</body>
</html>
